package com.handlers;

import com.MiniResultSetHanlder;
import com.MiniRowProcessor;

import java.sql.ResultSet;
import java.sql.SQLException;

public class MiniMapHandler implements MiniResultSetHanlder {

    private MiniRowProcessor convert;

    public MiniMapHandler() {
        this(MiniArrayHandler.DEFAULT_ROW_PROCESSOR);
    }

    public MiniMapHandler(MiniRowProcessor convert) {
        this.convert = convert;
    }

    @Override
    public Object handle(ResultSet rs) throws SQLException {
        return rs.next() ? convert.toMap(rs) : null;
    }
}
